<!--
 * @Author: gongjiuhui
 * @Date: 2022-04-21 17:17:58
 * @LastEditTime: 2022-05-13 11:43:05
 * @LastEditors: gong.jiuhui you@example.com
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \jk_one-stop_cloud_mobile_v1.0\src\views\apply\supplierDetail.vue
-->
<template>
  <div class="supplierDetail">
    <Navbar  @eventGetHeight="getHeight" :appTitle="title" />
    <!--头部-->
    <div id="headdd" class="d-head">
      <div class="content">
        <div class="left">
          <div class="title">
            {{$route.query.title}}
          </div>
          <div class="row">
            <span class="r-label">供应商编号：</span>
            <span class="r-column">{{ workOrderInfo.supplierCode || "--" }}</span>
          </div>
          <div class="row">
            <span class="r-label">供应商简称：</span>
            <span class="r-column">{{
              workOrderInfo.shortName || "--"
            }}</span>
          </div>
         
        </div>
        <div class="right">
            <img  class="rightImg" v-if="workOrderInfo.flowStatus == 'RUNNING'" src="@/assets/img/shenpizhong.png" alt="">
            <img  class="rightImg" v-if="workOrderInfo.flowStatus == 'AGREE'" src="@/assets/img/yitongguo.png" alt="">
            <img  class="rightImg" v-if="workOrderInfo.flowStatus == 'REFUSE'" src="@/assets/img/yijujue.png" alt="">
            <img  class="rightImg" v-if="workOrderInfo.flowStatus == 'TERMINATED'" src="@/assets/img/yichehui.png" alt="">
        </div>
      </div>
    </div>

    <!-- taps-->
    <!--锚点选项卡-->
    <van-tabs v-model="active" scrollspy sticky ref="vtapid" :lazy-render="false" :offset-top="runingHeight">
      <!--基本信息 -->
      <van-tab title="客户联系人" :style="calssDD">
        <div class="otherTaps"  v-for="(item, index) in workOrderInfo.erpCustomerContactInfoVoList"
            :key="index">
          <div class="title">
            <span class="icon"></span>
            <span class="content">客户联系人<span v-if="workOrderInfo.erpCustomerContactInfoVoList.length!=1">{{ index + 1 }}</span></span>
          </div>
          <div class="content">
            <div class="row">
              <span class="r-label">姓名：</span>
              <span class="r-column">{{item.contactName || "--"}} </span>
            </div>
            <div class="row">
              <span class="r-label">职务：</span>
              <span class="r-column">{{item.contactPost || "--"}}</span>
            </div>
            <div class="row">
              <span class="r-label">电话：</span>
              <span class="r-column">{{item.contactPhone || "--"}}</span>
            </div>
            <div class="row">
              <span class="r-label">邮箱：</span>
              <span class="r-column">{{item.contactEmail || "--"}}</span>
            </div>
          </div>
        </div>
      </van-tab>
      <!--操作报工 -->
      <van-tab title="供应商">
         <div class="otherTaps" v-for="(item, index) in workOrderInfo.erpSupplierAccountInfoVoList" :key="index">
          <div class="title">
            <span class="icon"></span>
            <span class="content">供应商收款账户<span v-if="workOrderInfo.erpSupplierAccountInfoVoList.length!=1">{{ index + 1 }}</span></span>
          </div>
          <div class="content">
            <div class="row">
              <span class="r-label">户名：</span>
              <span class="r-column">{{item.accountName || "--"}}</span>
            </div>
            <div class="row">
              <span class="r-label">开户行：</span>
              <span class="r-column">{{item.accountBank  || "--"}}</span>
            </div>
            <div class="row">
              <span class="r-label">账号：</span>
              <span class="r-column">{{item.accountNumber || "--"}}</span>
            </div>
          </div>
        </div>
      </van-tab>
      <!--其它 -->
      <van-tab title="其它">
        <div class="otherTaps">
          <div class="title">
            <span class="icon"></span>
            <span class="content">其它</span>
          </div>
          <div class="content">
            <div class="row">
              <span class="r-label">备注：</span>
              <span class="r-column"
                >{{workOrderInfo.remark}}</span
              >
            </div>
            <div class="row">
              <span class="r-label">附件：</span>
              <span class="r-column">
                <upload
                  class="fileclass"
                  iconType="fj"
                  @fileChange="fileChange"
                  :fileIds="workOrderInfo.attachment"
                  :showUpload="false"
                ></upload>
              </span>
            </div>
          </div>
        </div>
      </van-tab>
      <!--审批流程 -->
      <van-tab title="审批流程" v-if="workOrderInfo.flowInstId">
        <div class="otherTaps" :style="bottomHeight">
           <div class="title">
            <span class="icon"></span>
            <span class="content">审批流程</span>
          </div>
          <!--  ids="ERP_SUPPLIER"  -->
          <Examine  v-if="workOrderInfo.flowInstId" type="2"
          :id="workOrderInfo.flowInstId" ref="examine" 
          :showTitle="false"/>
              
        </div>
      </van-tab>
    </van-tabs>

       <!--提交按钮 -->
    <div class="search-bottom" v-if="$route.query.applyType == 'waiterDeal' && workOrderInfo.flowStatus == 'RUNNING'">
      <span class="btncancel" @click="cancel">拒绝</span>
      <span class="btnconfirm" @click="confirm">同意</span>
    </div>
  </div>
</template>

<script>
import { erpSupplierQueryById} from "@/api/mobile.js";
import Navbar from "@/components/navBar/navBar_right";
import upload from "@/components/upload/upload";
import Examine from "@/components/examine";
import { numFormat } from '@/utils/util'
import { getEnableOne } from "@/api/api";
export default {
  name: "recordDetail",
  components: { Navbar, upload,Examine},
  data() {
    return {
      topmenuHeiht:"",
      showFLow:true,
      bodyHeight:"",
      runingHeight: 0,
      bottomHeight:"padding-bottom:1.5rem",
      calssDD: "",
      numFormat,
      parentId:"",
      tableData:[],
      workOrderInfo:{},
      reasonArr: [],//不合格原因
      title: this.$route.meta.title,
      tabList: [
        { name: "发货记录", value: "1" },
        { name: "开票记录", value: "2" },
        { name: "收款记录", value: "2" },
      ],
      active: 0,
      fileIds: "1514159656052879361,1514159725032402946",
    };
  },
  //  watch: {
  //   runingHeight(n, o) {
  //     console.log(n, o);
  //     if (n || n == 0) {
  //       // alert("111")
  //      this.runingHeight=n
        
  //      this.$refs.vtapid.resize()
        
  //     }
  //   },
  // },
  mounted() {
    
  },
  created() {
    this.parentId = this.$route.query.id
    this.getDetail()
    
  },
  methods: {
     isShowFLow(){
       getEnableOne({ id: "ERP_SUPPLIER", type: "add" }).then((res) => {
        if (res.result && res.result == "false") {
          this.showFLow = false;
           this.initHeight(this.topmenuHeiht)
        } else {
          this.showFLow = true;
           this.initHeight(this.topmenuHeiht)
        }

       
      });   
     },
    getHeight(data) {
        let topdd=this.GLOBAL.currentEnvironment ? '0' : '46'
        this.topmenuHeiht=data
        this.runingHeight =data+document.getElementById("headdd").offsetHeight-5;
        this.calssDD = "margin-top:" + (this.runingHeight - topdd) + "px";
       this.isShowFLow();
    },
    initHeight(data){
      // alert(data)
      console.log(data,'计算高度')
      this.bodyHeight=document.body.clientHeight;//屏幕高度
       if(this.bodyHeight>=667){
        if(this.showFLow){
           this.bottomHeight="padding-bottom:1.5rem";
        }else{
           this.bottomHeight="padding-bottom:3.5rem";
          //  alert("ddddddd")

        }
      }
      if(this.bodyHeight>=736){
        if(this.showFLow){
           this.bottomHeight="padding-bottom:2rem";
        }else{
           this.bottomHeight="padding-bottom:4rem";

        }
        
      }
      if(this.bodyHeight>=812){
        if(this.showFLow){
           this.bottomHeight="padding-bottom:2.5rem";
        }else{
          this.bottomHeight="padding-bottom:4.5rem";
        }
         
      }
      if(this.bodyHeight>=844){
        if(this.showFLow){
           this.bottomHeight="padding-bottom:2.8rem";
        }else{
          this.bottomHeight="padding-bottom:4.8rem";
        }
         
      }
      if(this.bodyHeight>=896){
        if(this.showFLow){
           this.bottomHeight="padding-bottom:3rem";
        }else{
           this.bottomHeight="padding-bottom:5rem";
        }
      }
     
   
    },
    cancel() {
          // approveType 1:同意 0:拒绝
      this.$router.push({
        path: "/approval",
        query: { approveType: 0, taskId: this.$route.query.taskId},
      });
    },
    confirm() {
        this.$router.push({
        path: "/approval",
        query: { approveType: 1, taskId: this.$route.query.taskId },
      }); 
    },
    fileChange(ids) {
      console.log(ids);
      this.formData.attachment = ids;
    },
    getDetail() {
      erpSupplierQueryById({id:this.parentId}).then((res) => {
        if (res.success) {
          if (res.result) {
            this.workOrderInfo = res.result
          }
        } else {
            this.$toast(res.message);
        }
      })
    },
  },
};
</script>
<style lang="scss" scoped>
.supplierDetail {
  height: 100vh;
  overflow-y: scroll;
  background: #ffffff;
  // background: green;
  .d-head {
    position: fixed;
    width: 100%;
    padding: 0.16rem 0.16rem 0.16rem 0.16rem;
    background: #ffffff;
    z-index: 999;
    
    .content {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .left {
        width: 2.8rem;
        // border: 1px solid red;
        .title {
          font-size: 0.16rem;
          font-family: PingFang SC;
          font-weight: 500;
          color: #191f25;
          line-height: 0.22rem;

          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          -o-text-overflow: ellipsis;
        }
        .row {
          font-size: 0.14rem;
          font-family: PingFang SC;
          font-weight: 400;
          color: #888888;
          margin-top: 0.16rem;
          display: flex;
          .r-label {
          color: #888888;
      
        }
        .r-column {
          
          color: #191f25;
        
        }
        }
      }
      .right {
        // border: 1px solid red;
        width: 0.6rem;
        .rightImg {
          display: block;
          width: 0.55rem;
          height: 0.55rem;
          //   margin-left: 0.45rem;
          // border: 1px solid blue;
        }
      }
    }
  }

  .otherTaps {
    
    background: #ffffff;
    padding: 0.16rem;
     border-top:0.1rem solid rgb(245, 245, 245);
    .title {
      padding-bottom: 0.1rem;
      border-bottom: 1px solid #eeeeee;
      .icon {
        display: inline-block;
        width: 0.03rem;
        height: 0.14rem;
        background: #1890ff;
      }
      .content {
        width: 0.63rem;
        height: 0.16rem;
        font-size: 0.16rem;
        font-family: PingFang SC;
        font-weight: bold;
        color: #191f25;
        line-height: 0.22rem;
        margin-left: 0.1rem;
      }
    }
    .content {
      .row {
        font-size: 0.14rem;
        font-family: PingFang SC;
        font-weight: 400;
        margin-top: 0.16rem;
        display: flex;
        .r-label {
          color: #888888;
        //   display: block;
          // width: 0.6rem;
          //   border: 1px solid red;
        }
        .r-column {
        //   display: block;
          color: #191f25;
          width: 2.5rem;
          white-space:normal;word-break:break-all;word-wrap:break-word;

          //   border: 1px solid red;
          //    width: 1rem;
        }
      }
      .fhrow {
        display: flex;
        .fhImg {
          width: 0.55rem;
          height: 0.55rem;
          border-radius: 0.1rem;
        }
        .rt-column {
            width: 2.55rem;
        //   height: 2.55rem;
          margin-left: 0.2rem;
          .rt-title {
            font-size: 0.16rem;
            font-family: PingFang SC;
            font-weight: 500;
            color: #191f25;
            margin-bottom: 0.16rem;
          }
          .rt-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 0.23rem;
            .column {
            //    border: 1px solid red;
               width: 1.5rem;
              .column-t {
                font-size: 0.14rem;
                font-family: PingFang SC;
                font-weight: 400;
                color: #888888;
                display: block;
                width: 100%;
                margin-bottom: 0.03rem;
                
              }
              .column-c {
                font-size: 0.16rem;
                font-family: PingFang SC;
                font-weight: 400;
                color: #191f25;
                display: block;
                width: 100%;
              }
            }
          }
        }
      }
    }
  }
  .search-bottom {
    height: 0.5rem;
    width: 100%;
    background: #ffffff;
    // background: red;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    bottom: 0px;
    padding: 0.11rem;
    .btnconfirm {
      width: 1.72rem;
      height: 0.39rem;
      background: #1890ff;
      border-radius: 0rem;
      text-align: center;
      line-height: 0.39rem;
    }
    .btncancel {
      width: 1.72rem;
      height: 0.39rem;
      background: #f6f6f6;
      border: 0.01px solid rgba(25, 31, 37, 0.12);
      border-radius: 0rem;
      text-align: center;
      line-height: 0.39rem;
    }
  }
}
</style>
<style>
.van-tabs__line {
  background-color: #1890ff;
}
.van-tab--active {
  color: #1890ff;
}
</style>